home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Selection.h
-
- Contains: xxx put contents here xxx
-
- Written by: Essam Zaky
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 1/4/94 EZ clean up
- <1> 1/4/94 EZ first checked in
-
- */
-
- #ifndef _Selection_
- #define _Selection_
-
- #ifndef _ToolBoxDump_
- #include "ToolBoxDump.h"
- #endif
-
- #ifndef _TextensionCommon_
- #include "TextensionCommon.h"
- #endif
-
- #ifndef _RunObject_
- #include "RunObject.h"
- #endif
- //***************************************************************************************************
-
- //constants and types for ClickLoop message
- const ushort kAutoScroll = 1;
-
- typedef void (*ClickLoopProcPtr)(unsigned short message, void* data, void* refCon);
-
-
- //***************************************************************************************************
-
- inline void InitSelection() {}
- inline void EndSelection() {}
- //***************************************************************************************************
-
- #ifdef __SC__
- class __machdl CTextension; //later
- class __machdl CTextensionDisplay; //later
- #else
- class CTextension; //later
- class CTextensionDisplay; //later
- #endif
-
- class CSelection : public HandleObject {
- public:
- //-----
- CSelection();
-
- void ISelection();
-
- void SetHandlers(CTextension* textension, CTextensionDisplay* display);
-
- virtual void Free();
-
- #ifdef txtnNever
- virtual CSelection* CreateEmptyClone();
- #endif
-
- inline void SetAutoScroll(Boolean flag) {fAutoScroll = flag;}
-
- Boolean Click(const EventRecord* event, TClickCommandInfo* clickCommandInfo
- , ClickLoopProcPtr clickProc = nil, void* clickProcData = nil);
-
- void ArrowKey(unsigned char key, long modifiers);
-
- void Activate(Boolean activ, Boolean turnSelOn =true);
-
- Boolean Idle();
- unsigned long GetIdleTime(); //Idle should be called after the returned value (in Ticks)
-
- Boolean SetCursor(Point mousePt);
- /*returns false if the cursor is outside textension area
- */
-
- void Draw();
- inline void DisableDrawing() {--fSelectionVisLevel;}
- inline void EnableDrawing() {++fSelectionVisLevel;}
- inline Boolean IsDrawEnabled() {return fSelectionVisLevel >= 0;}
-
- void SetDrawInactivSelStat(Boolean drawIt);
- inline Boolean GetDrawInactivSelStat() {return fDrawInactivSel;}
-
- void Invalid(Boolean turnSelOff = false);
-
- void SetSelStat(char newSelStat);
- inline char GetSelStat() const {return fSelStat;}
-
- void GetSelectionRange(TOffsetRange* selRange) const;
-
- Boolean SetSelectionRange(const TOffsetRange& selRange, Boolean forceOn = false);
-
- void ExtendSelection(TOffsetRange extRange);
-
- void AdjustCharOffset(TOffset* charOffset);
-
- #ifdef txtnNever
- void SetCaretDirection(const CRunObject* caretRun);
- #endif
-
- void DelayCaret();
-
- void GetCaretRect(TxtnLongRect* caretRect); //in abs coord
-
- void GetRangePosition(TOffsetRange theRange, RunPositionPB* positionPb);
-
- protected:
- //--------
- CTextension* fTextension;
- CTextensionDisplay* fDisplay;
-
- virtual void DoClickLoop(ushort message, void* data);
-
- private:
- //------
- long fClickTime;
- Point fClickPoint;
- char fCountClick;
- Boolean fAutoScroll;
-
- char fSelStat;
- Boolean fDrawn;
- /*useful in many cases, most important when calling "SetSelStat" without Drawing the
- inactiv initialized value of "fSelStat". In this case "SetSelStat" can not know whether the old
- selStat was shown or not (to blank it before drawing the new one)*/
-
- long fCaretTime;
-
- char fCaretDir;
- Boolean fUserCaret;
- //I believe, The caret shouldn't change position with keyboard script changes if the user has chosen this caret position
-
- Boolean fDrawInactivSel;
-
- TxtnLongRect fCaretRect; //fCaretRect.top < 0 ==> caret rect is not valid
-
- #ifdef txtnMultiFrames
- long fCaretFrame;
- #endif
-
- TOffsetRange fSelRange;
-
- long fUpDownArrowsPix;
-
- static long fOSCaretTime;
- static RgnHandle fSelectRgn;
- static char fSelectionVisLevel;
- /*
- declared global when foot notes have been implemented, in this case user may want to hide draw
- across calls which may change the context (and thus the Selection)
- */
- //---------------------------------------------------
-
-
- Boolean GetClickRange(TOffsetRange* clickRange, short countClicks =0);
-
- Boolean CalcClickPoint(long scrollTicks, LongPoint* scrollVals);
-
- void SetSelStart(TOffset newSelStart);
- void SetSelEnd(TOffset newSelEnd);
- void DragSelection(TOffsetRange centerRange, ClickLoopProcPtr clickProc = nil, void* clickProcData = nil);
-
- void DrawInactivSelection(const Rect* selRect = nil) const;
- //if selRect is nil, select fSelectRgn
-
- void PreSelection() const;
-
- void PostSelection() const;
-
- void SelectRange(TOffsetRange range2Select, char caretDir);
-
- void SelectFrame(long frameNo, TOffsetRange range2Select
- , long firstLine, long lastLine, char caretDir) const;
- void SelectLine(long lineNo, long frameNo, TOffsetRange range2Select
- , char caretDir, TxtnLongRect* lineRect) const;
- void SelectRect(const TxtnLongRect* theRect, long frameNo
- , Boolean useHilitColor = true, Boolean add2SelectRgn = true) const;
-
- void CalcRangeRect(TOffsetRange theRange, TxtnLongRect* absRect, Boolean lineBounds =true);
- //theRange is nil ==> cuurent sel range
-
- void CalcCaretRect();
-
- void SelectCaret();
-
- char GetCaretDirection() const;
-
- CRunObject* IsCustomSelection(const TOffsetRange* charRange =nil);
- CRunObject* IsPointInActivGraphics(Point thePt, const TOffsetRange& pointRange, RunPositionPB* posPb);
- };
- //*************************************************************************************************
-
- #endif
-